function [y_predict,MSE] = SVMR(train_data,train_labels,test_data,test_labels,Default)

predictions=[];
labels=[];
errors=[];
% scores=[];

if Default
    tic
    load("SVMR_BestModel.mat");
    toc
else
    BestModel = fitrsvm(train_data, train_labels, 'KernelFunction', 'gaussian', ...
        'KernelScale','auto',...
        'Standardize', true, ...
        'HyperparameterOptimizationOptions',struct('Optimizer','bayesopt', ...
        'KFold',5,...
        'MaxObjectiveEvaluations',200,...
        'Repartition',true, ...
        'NumGridDivisions',20), ...
        'OptimizeHyperparameters','auto');
    save("SVMR_BestModel",'BestModel');
end

y_predict=predict(BestModel,test_data);
MSE=mse(y_predict,test_labels);
error =zeros(length(test_data),1);
index = abs(y_predict-test_labels)>0.2;
error(index) = 1;
resultTable=table(test_data,test_labels,y_predict,error);
filename = 'SVMR.xlsx';
writetable(resultTable,filename,'Sheet',1,'Range','A1')
end